import random

USER_AGENTS = [
    # Chrome浏览器（不同版本和操作系统）
    "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
    "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36",
    "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36",
    "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36",

    # Firefox浏览器
    "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/119.0",
    "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/119.0",

    # Safari浏览器
    "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Safari/605.1.15",
    "Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Mobile/15E148 Safari/604.1",

    # 其他浏览器
    "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Edge/119.0.0.0 Safari/537.36",
    "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36 OPR/99.0.0.0"
]

# 常见的引用来源列表
REFERERS = [
    "https://www.google.com/",
    "https://www.baidu.com/",
    "https://www.bing.com/",
    "https://www.sogou.com/",
    "https://www.so.com/",
    "https://www.yahoo.com/",
    "https://www.dogpile.com/"
]

# 接受的语言列表
ACCEPT_LANGUAGES = [
    "en-US,en;q=0.9",
    "zh-CN,zh;q=0.9,en;q=0.8",
    "zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3",
    "ja-JP,ja;q=0.9,en;q=0.8",
    "ko-KR,ko;q=0.9,en;q=0.8"
]


def get_random_headers():
    headers = {
        'Connection': 'Keep-Alive',
        'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
        # 'accept-encoding': 'gzip, deflate, br, zstd',
        'Accept-Language': 'zh-CN,zh;q=0.9,zh-TW;q=0.8,en;q=0.7',
        'User-Agent': random.choice(USER_AGENTS),
        # 'cookie': 'bbs_sid=uglvr5hago7ce2ec0qlmjko8ah; bbs_token=ouwgm2ZQjDISkvWRcBkat1YE9_2BpMp4cQnT2eqnuFOxnyG_2FDzorPScmB1vxZ9sY75IbcFlCuCGhAL61hlIHHEIoWegEw_3D; Hm_lvt_041715a44f3d6718f1e69867b53b8aa0=1760105869,1760156972,1760192379,1760229246; HMACCOUNT=0EF7018863B2E101; cf_clearance=72qQRqDvNXD5VvyxxAPFb6TNSwUlKYF1hTJv8x.kPNE-1760230184-1.2.1.1-c31fYWUqnte2G49Yc5bUVUPKIc7TvovUHTYzKOjycZicQaXXlNsNm.Xg6_1dwDVc3W87aFn5RIm3rfTw6idP9X5Y0tjQa5hcsaBJKK8ixuAamGdF7GvmPJVvjeKbpy0kHE4oyV89N9FvXkYdvh6PbAK6kDzTta1vpHoghq865bk_joIwnO58ImdpWaQWetlf50O0PQjG26E.w52XpTobSeiJ1KbHTfoQkfT2VwQHF0s; Hm_lpvt_041715a44f3d6718f1e69867b53b8aa0=1760230352'
    }
    return headers

def get_random_headers2():
    """生成随机的请求头信息"""
    headers = {
        'Connection': random.choice(['keep-alive', 'close']),
        'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
        'Accept-Language': random.choice(ACCEPT_LANGUAGES),
        'User-Agent': random.choice(USER_AGENTS),
        'Referer': random.choice(REFERERS),
        'Accept-Encoding': 'gzip, deflate, br',
        'DNT': random.choice(['0', '1']),  # 是否开启禁止追踪
        'Upgrade-Insecure-Requests': '1',
        'Sec-Fetch-Dest': 'document',
        'Sec-Fetch-Mode': 'navigate',
        'Sec-Fetch-Site': random.choice(['none', 'same-origin', 'cross-site']),
        'Cache-Control': random.choice(['max-age=0', 'no-cache'])
    }
    return headers